package com.example.ex5_springboot.mappers;

import com.example.ex5_springboot.pojo.UserLogin;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserLoginMapper {
    @Select("select * from user where user_name = #{id}")
    UserLogin getUserInfoById(int id);

    @Select("select user_name,name,college,enable from user")
    List<UserLogin> getUserInfo();

    @Update("update user set enable = #{enable} where user_name = #{id}")
    int changeEnable(int enable,int id);

    @Update("update user set college = #{college},name = #{name} where user_name = #{id}")
    int editUserChangeInfo(int id,String college,String name);

    @Insert("insert into user(user_name,user_pwd,college,name,enable,petName) value (#{id},11111,#{college},#{name},0,'默认昵称')")
    int insertUser(int id,String college,String name);

    @Update("update user set petName = #{petName},user_pwd = #{user_pwd} where user_name = #{id}")
    int updateUser(int id,String petName,String user_pwd);
}
